﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;

public partial class Control_WebInfo_ImgTitle : System.Web.UI.UserControl
{
    MODEL.WebInfo MWI = new MODEL.WebInfo();
    MODEL.WebInfo _MWI = new MODEL.WebInfo();

    BLL.WebInfo BWI = new BLL.WebInfo();



    protected void Page_Load(object sender, EventArgs e)
    {
        ControlDataInit();
    }


    #region ControlDataInit
    protected void ControlDataInit()
    {
        try
        {
            if (Request.QueryString["WebInfoID"] == null)
            {
                throw new Exception("参数ID接收失败");
            }
            else
            {
                MWI.WI_ID = Convert.ToInt32(Request.QueryString["WebInfoID"]);
            }

            _MWI = BWI.GetDataByID(MWI);

            LB_WebInfoContent.Text = _MWI.WI_Content;

            BWI.HitsPlus1(MWI);

            ImgTitleInit();

        }
        catch (Exception ex)
        {
            LB_WebInfo_ImgTitle.Text = ex.Message;
        }
    }
    #endregion


    #region 图像标题URL绑定 [初始化]
    protected void ImgTitleInit()
    {
        try
        {
            if (Request.QueryString["WebInfoID"] == null)
            {
                throw new Exception("参数ID接收失败");
            }

            switch (Request.QueryString["WebInfoID"].ToString())
            {
                case "1":

                    if (File.Exists(Server.MapPath("~/") + "Control/img/About.jpg"))
                    {
                        IMG_WebInfoImage.ImageUrl = "~/Control/img/About.jpg";
                    }
                    else if (File.Exists(Server.MapPath("~/") + "Control/img/About.gif"))
                    {
                        IMG_WebInfoImage.ImageUrl = "~/Control/img/About.gif";
                    }
                    else
                    {
                        throw new Exception("无法找到图像文件，参数名\"About\"");
                    }
                    
                    break;


                case "2":

                    if (File.Exists(Server.MapPath("~/") + "Control/img/Contact.jpg"))
                    {
                        IMG_WebInfoImage.ImageUrl = "~/Control/img/Contact.jpg";
                    }
                    else if (File.Exists(Server.MapPath("~/") + "Control/img/Contact.gif"))
                    {
                        IMG_WebInfoImage.ImageUrl = "~/Control/img/Contact.gif";
                    }
                    else
                    {
                        throw new Exception("无法找到图像文件，参数名\"Contact\"");
                    }

                    break;
            }

        }
        catch (Exception ex)
        {
            LB_WebInfo_ImgTitle.Text = ex.Message;
        }
    }
    #endregion
}
